package com.ch999.comparedata.config;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Order(-1)
@Component
public class CompareAspect {

    @Pointcut("@annotation(CompareData)")
    public void poincut(){}


    @Before("poincut()")
    public void getId(JoinPoint joinPoint){
        ContextHolder.setContextHolder(Long.valueOf(System.currentTimeMillis()).toString());
    }

    @After("poincut()")
    public void remove(){
        ContextHolder.remove();
    }
}
